package com.cjjd.c.feature.home.chekin.checklist_detail;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cjjd.c.R;
import com.cjjd.c.base.ActionBarActivity;
import com.cjjd.c.bean.CheckInDetailBean;
import com.cjjd.c.utils.DateTimeUtil;

import butterknife.Bind;
import butterknife.BindInt;
import butterknife.ButterKnife;

/**
 * ----------------------------------
 * Created by xyd on 2017/12/20.
 * <p/>
 * 描  述：
 * <p/>
 * 修订历史:
 * ----------------------------------
 */

public class CancelOrderActivity extends ActionBarActivity {


    @Bind(R.id.dingdanlaiyuan_layou)
    LinearLayout dingdanlaiyuan_layou;
    @Bind(R.id.haokebi_layout)
    LinearLayout haokebi_layout;

    @Bind(R.id.tv_order_form)
    TextView tvOrderForm;
    @Bind(R.id.tv_room_num)
    TextView tvRoomNum;
    @Bind(R.id.tv_order_person_name)
    TextView tvOrderPersonName;
    @Bind(R.id.tv_phone)
    TextView tvPhone;
    @Bind(R.id.tv_order_person_id)
    TextView tvOrderPersonId;
    @Bind(R.id.tv_time_arrive)
    TextView tvTimeArrive;
    @Bind(R.id.tv_time_for_settle_leave)
    TextView tvTimeForSettleLeave;
    @Bind(R.id.tv_hotel_style)
    TextView tvHotelStyle;
    @Bind(R.id.tv_order_id)
    TextView tvOrderId;
    @Bind(R.id.btn_next)
    Button btnNext;
    @Bind(R.id.tv_hotel_name)
    TextView tvHotelName;
    @Bind(R.id.tv_roomMoney)
    TextView tvRoomMoney;
    @Bind(R.id.tv_depositMoney)
    TextView tvDepositMoney;
    @Bind(R.id.tv_coupon)
    TextView tvCoupon;
    @Bind(R.id.tv_specialDemand)
    TextView tvSpecialDemand;
    @Bind(R.id.tv_receipt_need)
    TextView tvReceiptNeed;
    @Bind(R.id.tv_pay_mode)
    TextView tvPayMode;

    @Bind(R.id.ll_change_order)
    LinearLayout ll_change_order;

    private CheckInDetailBean.Order order;

    @Override
    public Object getTitleString() {
        return "订单详情";
    }

    @Override
    public int getContentView() {
        return R.layout.fragment_checkin_detail;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);
        order = (CheckInDetailBean.Order) getIntent().getSerializableExtra("orderBean");
        if (order != null) {
            changeUI(order);
        }
    }

    private void changeUI(CheckInDetailBean.Order order) {

        if (order == null) {
            return;
        }

        if(TextUtils.isEmpty(order.orderSource)){
            dingdanlaiyuan_layou.setVisibility(View.GONE);
        }else{
            tvOrderForm.setText(order.orderSource);
            dingdanlaiyuan_layou.setVisibility(View.VISIBLE);

        }

        //dada TODO 判断好客币
        /**
         *
        if(TextUtils.isEmpty(order.)){
            haokebi_layout.setVisibility(View.GONE);
        }else{
            haokebi_layout.setVisibility(View.VISIBLE);
//            tv_coupon
            tvCoupon.setText("好客币");
        }

         */

        tvHotelName.setText(order.hotelName);
        tvTimeForSettleLeave.setText("入离店日期：" + DateTimeUtil.getNY(order.checkInDate) + "-" + DateTimeUtil.getNY(order.checkOutDate)
                + "  共" + order.checkInDayNum + "天");
        tvHotelStyle.setText(order.roomTypeName + "|" + order.breakfastTypeName);//+ "|" + order.bedInfo + "|" + order.windowInfo);
        tvOrderId.setText("订单编号: " + order.orderId);

        tvOrderForm.setText(order.orderSource);
        tvOrderPersonName.setText(order.reserveMan);
        tvRoomNum.setText(order.roomNum + "间");
        tvPhone.setText(order.reserveManMobile);
        tvOrderPersonId.setText(order.reserveManIdCard);
        tvTimeArrive.setText(order.arriveTime);


        if ("0".equals(order.roomPayType)) {
            tvRoomMoney.setText("未支付" + order.roomMoney + "元");
        } else if ("1".equals(order.roomPayType)) {
            tvRoomMoney.setText("已支付" + order.roomMoney + "元");
        }

        if ("0".equals(order.roomPayType)) {
            tvDepositMoney.setText("未支付" + order.depositMoney + "元");
        } else if ("1".equals(order.roomPayType)) {
            tvDepositMoney.setText("已支付" + order.depositMoney + "元");
        }

        tvCoupon.setText(order.discountInfo);
        tvSpecialDemand.setText(order.specialDemand);
        tvPayMode.setText("");
        tvReceiptNeed.setText("可能需要");


    }

}
